package com.ruoyi.user.controller.app;

import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.result.Pages;
import com.ruoyi.common.core.pojo.vo.BaseVO;
import com.ruoyi.common.core.pojo.vo.PageVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.user.model.pojo.request.app.AppDressSearchRequest;
import com.ruoyi.user.model.pojo.request.app.dress.AppDressUseRequest;
import com.ruoyi.user.model.pojo.result.app.AppDressInfoResult;
import com.ruoyi.user.service.IDressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;


@Tag(name = "App-装扮中心相关", description = "App-装扮中心相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "dress")
public class AppDressController {

    @Autowired
    private IDressService iDressService;


    @Operation(description = "装扮列表", summary = "装扮列表")
    @GetMapping("listPage")
    public PageVO<AppDressInfoResult> listPage(@ParameterObject @Valid AppDressSearchRequest request) {
        Pages<AppDressInfoResult> pages = iDressService.listPage(request, SecurityContextHolder.getUserId());
        return Result.page(pages);
    }

    @Operation(description = "使用装扮", summary = "使用装扮")
    @PostMapping("use")
    public BaseVO use(@RequestBody @Valid AppDressUseRequest request) {
        boolean use = iDressService.use(request, SecurityContextHolder.getUserId());
        return Result.successOrFail(use);
    }


}
